import { createApp } from 'vue'
import './style.css'
import App from './App.vue'

import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import zhCn from 'element-plus/es/locale/lang/zh-cn'

import VueLazyload from 'vue-lazyload';
import loadImg from '@/assets/loading.svg';

import 'normalize.css/normalize.css'
import '@/assets/global.css'
import '@/assets/cover.css'

import router from '@/router/index.ts'
import store from '@/store/index.ts'

import './permission.ts';

import * as Icons from '@element-plus/icons-vue'

const app = createApp(App);

for (let iconName in Icons) {
  app.component(iconName, Icons[iconName as keyof typeof Icons])
}

app
  .directive('focus', (el) => {
    if (el.querySelector("input")) {
      el.querySelector("input").focus();          
    } else {
      el.querySelector("textarea").focus();          
    }
  })
  .use(ElementPlus, {
    locale: zhCn
  })
  .use(router)
  .use(store)
  .use(VueLazyload, {
    loading: loadImg
  })
  .mount('#app')
